package other.nowcoder.medium;

import java.util.Scanner;

/**
 * @author bruin_du
 * @description MP3光标位置
 * https://www.nowcoder.com/practice/eaf5b886bd6645dd9cfb5406f3753e15?
 * tpId=37&&tqId=21287&rp=1&ru=/activity/oj&qru=/ta/huawei/question-ranking
 * @date 2022/5/18 14:41
 **/
public class MP3CursorPosition {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt();
            String str = in.next();
            int[] arr = new int[Math.min(n, 4)];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = i + 1;
            }
            int index = 1;
            for (int i = 0; i < str.length(); i++) {
                char ch = str.charAt(i);
                if (ch == 'U') {
                    if (index == 1) {
                        if (arr[0] == 1) {
                                for (int j = 0; j < arr.length; j++) {
                                    arr[j] = n - arr.length + 1 + j;
                                }
                                index = arr.length;
                        } else {
                                for (int j = 0; j < arr.length; j++) {
                                    arr[j] -= 1;
                                }
                        }
                    } else {
                        --index;
                    }
                }
                if (ch == 'D') {
                    if (index == arr.length ) {
                        if (arr[arr.length - 1] == n) {
                            for (int j = 0; j < arr.length; j++) {
                                arr[j] = j + 1;
                            }
                            index = 1;
                        } else {
                            for (int j = 0; j < arr.length; j++) {
                                arr[j] += 1;
                            }
                        }
                    } else
                        ++index;
                }
            }
            for (int i = 0; i < arr.length; i++) {
                System.out.print(arr[i]);
                if (i != arr.length - 1)
                    System.out.print(" ");
            }
            System.out.println();
            System.out.println(arr[index - 1]);
        }
    }
}
